aboutsummaryrefslogtreecommitdiffstats
path: root/src/pages/article/[slug].tsx
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2022-01-06 17:55:24 +0100
committerArmand Philippot <git@armandphilippot.com>2022-01-06 18:14:42 +0100
commitb9c1953c79688fc3f536b7927692309c9780b5da (patch)
tree673a26c0b0a9cc587f89d1eea9af739c3f17daf2 /src/pages/article/[slug].tsx
parent544f8cd400f888464a18ee30836f63d4b93a0822 (diff)
refactor: reuse PostMeta components on single articles/pages
Diffstat (limited to 'src/pages/article/[slug].tsx')
-rw-r--r--src/pages/article/[slug].tsx25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/pages/article/[slug].tsx b/src/pages/article/[slug].tsx
index 493f061..e8df85e 100644
--- a/src/pages/article/[slug].tsx
+++ b/src/pages/article/[slug].tsx
@@ -9,7 +9,7 @@ import { config } from '@config/website';
import { t } from '@lingui/macro';
import { getAllPostsSlug, getPostBySlug } from '@services/graphql/queries';
import { NextPageWithLayout } from '@ts/types/app';
-import { ArticleProps } from '@ts/types/articles';
+import { ArticleMeta, ArticleProps } from '@ts/types/articles';
import { loadTranslation } from '@utils/helpers/i18n';
import { addPrismClasses, translateCopyButton } from '@utils/helpers/prism';
import { GetStaticPaths, GetStaticProps, GetStaticPropsContext } from 'next';
@@ -32,6 +32,13 @@ const SingleArticle: NextPageWithLayout<ArticleProps> = ({ post }) => {
title,
} = post;
+ const meta: ArticleMeta = {
+ author,
+ commentCount: comments.length,
+ dates,
+ thematics,
+ };
+
const router = useRouter();
const locale = router.locale ? router.locale : config.defaultLocale;
@@ -51,17 +58,15 @@ const SingleArticle: NextPageWithLayout<ArticleProps> = ({ post }) => {
<meta name="description" content={seo.metaDesc} />
</Head>
<article>
- <PostHeader
- author={author}
- dates={dates}
- intro={intro}
- title={title}
- thematics={thematics}
- />
- <ToC />
+ <PostHeader intro={intro} meta={meta} title={title} />
+ <aside>
+ <ToC />
+ </aside>
<div dangerouslySetInnerHTML={{ __html: content }}></div>
<PostFooter subjects={subjects} />
- <Sharing title={title} excerpt={intro} />
+ <aside>
+ <Sharing title={title} excerpt={intro} />
+ </aside>
<section>
<h2>{t`Comments`}</h2>
<CommentsList comments={comments} />